// HOW TO RUN : ./main < 22out.txt > result.txt; result is the last number

#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <string>
#include <vector>

using namespace std;

int main()
{


//	PRE-PROCESSING: convert , into \n and use a spreadsheet program to sort all the words.

/*
	freopen("22.txt", "r", stdin);
	freopen("22out.txt", "w", stdout);
	
	char c;
	int i = 0;
	while (scanf("%c", &c) != EOF)
	{
		if (c == ',') cout << " " << i++ << endl;
		else cout << c;
	}
*/

	int total = 0, count = 0;
	string s;
	while (getline(cin, s))
	{
		s.erase(s.size()-1);
		s.erase(0, 1);
		
		cout << s << endl;

		int sum = 0;
		for (int i = 0; i < s.size(); i++) 
		{
			sum += s[i] - 'A' + 1;
			cout << s[i]-'A'+1 << " ";
		}
		count++;
		cout << count << " " << sum*count << endl;

		total += sum * count;
	}

	cout << total << endl;

	return 0;
}
